package com.ryhx.main;

import java.io.File;

import com.ryhx.util.ConfigUtil;

/**
 * 文件目录生成器
 * @author yaojinshan
 * @since 2017-08-02 16:56
 */
public class FileDirProducer {
	public static void main(String[] args) {
		createDir();
	}

	/**
	 * 创建后续 生成的文件  的存放目录
	 */
	public static void createDir() {
		if (ConfigUtil.simpleModelNameLower != null && !"".equals(ConfigUtil.simpleModelNameLower)) {
			File modelDir = new File("source/" + ConfigUtil.simpleModelNameLower);
			if (!modelDir.exists()) {
				try {
					modelDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"目录失败");
				}
			}
			File subControllerDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/controller");
			if (!subControllerDir.exists()) {
				try {
					subControllerDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/controller目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/controller目录失败");
				}
			}
			File subEntityDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/entity");
			if (!subEntityDir.exists()) {
				try {
					subEntityDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/entity目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/entity目录失败");
				}
			}
			File subMapperDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/mapper");
			if (!subMapperDir.exists()) {
				try {
					subMapperDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/mapper目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/mapper目录失败");
				}
			}
			File subModelDaoDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/dao");
			if (!subModelDaoDir.exists()) {
				try {
					subModelDaoDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/dao目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/dao目录失败");
				}
			}
			File subDaoDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/dao/impl");
			if (!subDaoDir.exists()) {
				try {
					subDaoDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/dao/impl目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/dao/impl目录失败");
				}
			}
			File subModelServiceDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/service");
			if (!subModelServiceDir.exists()) {
				try {
					subModelServiceDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/service目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/service目录失败");
				}
			}
			File subServiceDir = new File("source/" + ConfigUtil.simpleModelNameLower+"/service/impl");
			if (!subServiceDir.exists()) {
				try {
					subServiceDir.mkdir();
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/service/impl目录成功");
				} catch (Exception e) {
					System.out.println("创建"+ConfigUtil.simpleModelNameLower+"/service/impl目录失败");
				}
			}
		}
	}

}
